

from django_filters.rest_framework import FilterSet,filters


from py_web.security.models import User, Role, Menu


# 用户表条件过滤
class UserFilter(FilterSet):

    nickname = filters.CharFilter(field_name='nickname', lookup_expr='icontains')
    phone = filters.CharFilter(field_name='phone', lookup_expr='exact')
    status = filters.CharFilter(field_name='status', lookup_expr='exact')

    class Meta:
        model = User   # 模型名
        fields = ['nickname', 'phone', 'status']


#角色过滤
class RoleFilter(FilterSet):

    roleName = filters.CharFilter(field_name='roleName', lookup_expr='icontains')
    status = filters.CharFilter(field_name='status', lookup_expr='exact')

    class Meta:
        model = Role   # 模型名
        fields = ['roleName', 'status']


class MenuFilter(FilterSet):

    menuName = filters.CharFilter(field_name='menuName', lookup_expr='icontains')
    status = filters.CharFilter(field_name='status', lookup_expr='exact')

    class Meta:
        model = Menu   # 模型名
        fields = ['menuName', 'status']